package me.zhengjie.controller;

import lombok.RequiredArgsConstructor;
import me.zhengjie.log.aop.WebLog;
import me.zhengjie.pojo.dto.AgvRequestLiftDto;
import me.zhengjie.pojo.dto.AgvReturnDto;
import me.zhengjie.pojo.vo.AgvTaskSubmitVo;
import me.zhengjie.service.AgvReturnService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wcs")
@RequiredArgsConstructor
public class AgvReturnController {
    private static final Logger haikang = LoggerFactory.getLogger("haiKang");

    private  final AgvReturnService agvReturnService;

    @PostMapping("/task/report")
    @WebLog(description = "WCS下发AGV任务", logName = "haiKang", category = "haiKang")
    public AgvTaskSubmitVo agvTaskReport(@RequestBody AgvReturnDto agvReturnDto) {
        haikang.info("haikang任务上报请求参数：{}",agvReturnDto);
        AgvTaskSubmitVo agvTaskSubmitVo = agvReturnService.agvTaskReport(agvReturnDto);
//        return agvTaskSubmitVo;
        haikang.info("haikang任务上报返回结果:{}",agvTaskSubmitVo);
        return agvTaskSubmitVo;
    }

    //AGV请求外设接口
    @PostMapping("/peripherals/report")
    @WebLog(description = "WCS接收AGV回报请求外设", logName = "haiKang", category = "haiKang")
    public AgvTaskSubmitVo agvRequestLift(@RequestBody AgvRequestLiftDto agvRequestLiftDto){
        haikang.info("请求外设接口回报：{}",agvRequestLiftDto);
        AgvTaskSubmitVo agvTaskSubmitVo = agvReturnService.agvRequestLift(agvRequestLiftDto);
        return agvTaskSubmitVo;
    }


}
